<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin:0;
            padding:0;
            outline:0   /* input a button img  浏览器轮廓容易不统一
                        ios android 移动端 webkit 统一了
                        webkit(开源内核) chrome(商业产品) ie */
        }
        body {
            color:#111;
        }
        a {
            text-decoration: none;
            color:inherit;
        } 
        .pj_tabbar{
            display:flex;
        }
        .pj_tabbar__item {
            flex:1;
            height:50px;
            border-bottom:1px solid #ddd;
        }
        .pj_tabbar__item a {
            display:block;
            line-height:50px;
            text-align: center;
        }
        .pj_tabbar__item a:first-child {
            border-right:1px solid #ddd;
        }
        .pj_tabbar__item_on {
            background-color: pink;
            color:white
        }
    </style>
</head>
<body>
    <!-- 手感 -->
    <div class="pj_tabbar">
        <div class="pj_tabbar__item pj_tabbar__item_on">
            <a href = "#" data-type="basic">
                basic
            </a>
        </div>
        <div class="pj_tabbar__item">
            <a href="#" data-type="super">
                super
            </a>
        </div>
    </div>
    <div class="list">

    </div>
    <script>
        const list = document.getElementsByClassName('list');
        const links = document.querySelectorAll('.pj_tabbar__item a');
        // const tabTypes = {
        //     basic: Symbol(), /*es6里新的简单数据类型*/
        //     super:Symbol()
        // }
        // java 等大型语言 tab切换 为了可读性 添加tabTypes 对象常量
        // 所有tab类型的管理 统一
        const tabTypes = {
            basic:'basic', /*es6里新的简单数据类型*/
            super:'super'
        }
        links.forEach(link=> {
            link.addEventListener('click',function(event) {
                // a 带来的交互感觉
                event.preventDefault();
                const type = event.target.dataset.type;
                const parent = this.parentNode;
                if(!parent.classList.contains('pj_tabbar__item_on')) {
                    document.querySelector('.pj_tabbar__item_on')
                    .classList.remove('pj_tabbar__item_on')
                    parent.classList.add('pj_tabbar__item_on')
                }
                if(type == tabTypes.basic) {
                    list.innerText = 'basic';
                    console.log('----')
                }
                if(type == tabTypes.super) {
                    list.innerText = 'super';
                    console.log('++++')
                }
            })
        })
    </script>
</body>
</html>